From ec15d20abac65bfda6c8e6396ce9fc2061f5067a Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Wed, 24 Apr 2024 14:52:57 +0100
Subject: ui(web): Show bookmark URL when maximizing a bookmark

---
 apps/web/app/dashboard/preview/[bookmarkId]/page.tsx | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

(limited to 'apps/web/app/dashboard/preview/[bookmarkId]/page.tsx')

diff --git a/apps/web/app/dashboard/preview/[bookmarkId]/page.tsx b/apps/web/app/dashboard/preview/[bookmarkId]/page.tsx
index 6cac7377..236f5447 100644
--- a/apps/web/app/dashboard/preview/[bookmarkId]/page.tsx
+++ b/apps/web/app/dashboard/preview/[bookmarkId]/page.tsx
@@ -1,18 +1,30 @@
+import { notFound } from "next/navigation";
 import BookmarkPreview from "@/components/dashboard/preview/BookmarkPreview";
 import { api } from "@/server/api/client";
+import { TRPCError } from "@trpc/server";
 
 export default async function BookmarkPreviewPage({
   params,
 }: {
   params: { bookmarkId: string };
 }) {
-  const bookmark = await api.bookmarks.getBookmark({
-    bookmarkId: params.bookmarkId,
-  });
+  let bookmark;
+  try {
+    bookmark = await api.bookmarks.getBookmark({
+      bookmarkId: params.bookmarkId,
+    });
+  } catch (e) {
+    if (e instanceof TRPCError) {
+      if (e.code === "NOT_FOUND") {
+        notFound();
+      }
+    }
+    throw e;
+  }
 
   return (
     <div className="max-h-screen">
-      <BookmarkPreview initialData={bookmark} />
+      <BookmarkPreview bookmarkId={bookmark.id} initialData={bookmark} />
     </div>
   );
 }
-- 
cgit v1.3-1-g0d28

